﻿using System.Data.Entity;
using System.Data.Entity.ModelConfiguration.Conventions;

namespace HpSocketIotGateway.Db.Code1st
{
    public class GatewayContext : DbContext
    {
        public GatewayContext()
            : base("name=GatewayContext")
        {
            // 禁用延迟加载
            Configuration.LazyLoadingEnabled = false;
        }

        protected override void OnModelCreating(DbModelBuilder modelBuilder)
        {
            // 禁用默认表名复数形式
            modelBuilder.Conventions.Remove<PluralizingTableNameConvention>();
            // 禁用一对多级联删除
            modelBuilder.Conventions.Remove<OneToManyCascadeDeleteConvention>();
            // 禁用多对多级联删除
            modelBuilder.Conventions.Remove<ManyToManyCascadeDeleteConvention>();
        }

        public DbSet<received_msg> received_msg { get; set; }
        public DbSet<send_ctr_cmd> send_ctr_cmd { get; set; }
        public DbSet<send_data> send_data { get; set; }
        public DbSet<controller> controllers { get; set; }

    }
}
